package Data;

import java.io.Serializable;
import java.util.Arrays;

public class ChatData implements Serializable {
    private static final long serialVersionUID = 5442710183388828792L;
    private byte[] sender_avatar;
    private byte[] receiver_avatar;
    private String sender_id;
    private String receiver_id;

    @Override
    public int hashCode()
    {
        final int prime=31;
        int result=1;
        result=prime*result+((sender_avatar==null)?0: sender_avatar.toString().hashCode());
        result=prime*result+((receiver_avatar==null)?0:receiver_avatar.toString().hashCode());
        result=prime*result+((sender_id==null)?0:sender_id.hashCode());
        result=prime*result+((receiver_id==null)?0:receiver_id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if(this==obj) return true;
        if(obj==null) return false;
        if(getClass()!=obj.getClass()) return false;
        ChatData other=(ChatData) obj;
        if(sender_id==null)
        {
            if(other.sender_id!=null) return false;
        }
        else if(!sender_id.equals(other.sender_id))
            return false;
        if(receiver_id==null)
        {
            if(other.receiver_id!=null) return false;
        }
        else if(!receiver_id.equals(other.receiver_id))
            return false;
        if(sender_avatar==null)
        {
            if(other.sender_avatar!=null) return false;
        }
        else if(!Arrays.equals(sender_avatar, other.sender_avatar))
            return false;
        if(receiver_avatar==null)
        {
            if(other.receiver_avatar!=null) return false;
        }
        else if(!Arrays.equals(receiver_avatar, other.receiver_avatar))
            return false;
        return true;
    }

    public ChatData(byte[] sender_avatar, byte[] receiver_avatar, String sender_id, String receiver_id) {
        this.sender_avatar = sender_avatar;
        this.receiver_avatar = receiver_avatar;
        this.sender_id = sender_id;
        this.receiver_id = receiver_id;
    }

    public byte[] getSender_avatar() {
        return sender_avatar;
    }

    public void setSender_avatar(byte[] sender_avatar) {
        this.sender_avatar = sender_avatar;
    }

    public byte[] getReceiver_avatar() {
        return receiver_avatar;
    }

    public void setReceiver_avatar(byte[] receiver_avatar) {
        this.receiver_avatar = receiver_avatar;
    }

    public String getSender_id() {
        return sender_id;
    }

    public void setSender_id(String sender_id) {
        this.sender_id = sender_id;
    }

    public String getReceiver_id() {
        return receiver_id;
    }

    public void setReceiver_id(String receiver_id) {
        this.receiver_id = receiver_id;
    }
}
